package com.qigao.mall.web.job;

import com.qigao.mall.api.PromGroupService;
import com.qigao.mall.service.impl.PromGroupServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * Copyright (C), 2020-2020
 * FileName: PromGroupJob
 * Author:   luiz
 * Date:     2020/10/15 17:34
 * Description: 团购自动开奖job
 */
@Component
public class PromGroupJob {
    private static final Logger logger= LoggerFactory.getLogger(PromGroupJob.class);
    @Resource
    private PromGroupService promGroupService;
    /**
     * 自动关闭团购订单
     * 1.关闭超时拼团
     */
    @Scheduled(fixedRate = 3000)
    public void autoClose(){
        promGroupService.autoClose();
    }
    /**
     * 处理已过期未完成团购
     * 1.自动发起退款
     */
    @Scheduled(fixedRate = 8000)
    public void autoRefund(){
        promGroupService.autoRefund();
    }

    /**
     * 处理在未过期范围内已完成团购
     * 1.未命中的发起退款
     * 2.已命中的进行分账
     */
    @Scheduled(fixedRate = 5000)
    public void autoSettle(){
        promGroupService.autoSettle();
    }
}
